<script setup>
import { ref, computed } from 'vue'
import ComponentList from './components/ComponentList.vue'
import Canvas from './components/Canvas.vue'
import CodePreview from './components/CodePreview.vue'
import AIChat from './components/AIChat.vue'
import AlgorithmVisualizer from './components/AlgorithmVisualizer.vue'

const canvas = ref(null)
const componentList = ref(null)

const canvasNodes = computed(() => canvas.value?.nodes || [])
const canvasConnections = computed(() => canvas.value?.connections || [])

const handleCanvasCleared = () => {
  componentList.value?.handleCanvasCleared()
}
</script>

<template>
  <el-container class="app-container">
    <el-aside width="300px" class="aside">
      <ComponentList ref="componentList" />
    </el-aside>
    
    <el-container>
      <el-main>
        <Canvas ref="canvas" @canvas-cleared="handleCanvasCleared" />
      </el-main>
      
      <el-footer height="280px" class="footer">
        <CodePreview 
          :nodes="canvasNodes" 
          :connections="canvasConnections" 
        />
      </el-footer>
    </el-container>
  </el-container>
  <AIChat />
  <AlgorithmVisualizer />
</template>

<style scoped>
.app-container {
  height: 100vh;
  background-color: #fff;
}

.aside {
  background-color: #f5f7fa;
  border-right: 1px solid #e6e6e6;
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.footer {
  background-color: #f5f7fa;
  border-top: 1px solid #e6e6e6;
  padding: 0;
}
</style>
